package com.awifi.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

//导入其它的配置类，此类将作为主配置类
@Import(DataSourceConfiguration.class)
@Configuration
public class JDBCConfiguration {

    @Bean
    public JdbcTemplate getJdbcTemplate(DataSourceConfiguration dataSourceConfiguration) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourceConfiguration.dataSource());
        return jdbcTemplate;
    }

    @Bean
    public DataSourceTransactionManager transactionManager(DataSourceConfiguration dataSourceConfiguration){
        DataSourceTransactionManager dst = new DataSourceTransactionManager(dataSourceConfiguration.dataSource());
        return dst;
    }

}
